<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>watch基础用法</title>
</head>

<body>


    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>


    <div id="Application">

    </div>
    <script>
        const App = Vue.createApp({
            setup() {
                const count = Vue.ref(0);
                Vue.watch(count, (val, oldVal) => {
                    console.log(val, oldVal);
                });

                setTimeout(() => {
                    count.value += 1; // 当值改变时执行
                }, 1000);
                return {

                }
            }
        })
        App.mount("#Application")
    </script>
</body>

</html>